﻿#region imports

using System.Collections.Generic;
using System.Linq;
using Codeplex.ODataTFS.Model.Entities;
using Codeplex.ODataTFS.Model.Serialization;

#endregion

namespace Codeplex.ODataTFS.Model.Repositories
{
	public class IterationPathRepository
	{
		private readonly TFSIterationPathProxy _proxy;

		public IterationPathRepository(TFSIterationPathProxy proxy)
		{
			_proxy = proxy;
		}

		public IterationPath GetOne(string path)
		{
			return _proxy.GetAllIterationPaths().SingleOrDefault(a => a.Path.Equals(path));
		}

		public IEnumerable<IterationPath> GetAll()
		{
			return _proxy.GetAllIterationPaths();
		}

		public IEnumerable<IterationPath> GetSubIterationsByIterationPath(string path)
		{
			return _proxy.GetSubIterations(path);
		}

		public IEnumerable<IterationPath> GetIterationPathsByProject(string projectName)
		{
			return _proxy.GetIterationsByProject(projectName);
		}
	}
}
